/****************************************************************************
 *
 * Copyright (C) 2003-2008 Los Alamos National Security, LLC
 *                         Packet Analytics Corporation
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License Version 2 as
 * published by the Free Software Foundation.  You may not use, modify or
 * distribute this program under any other version of the GNU General
 * Public License.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 *
 ****************************************************************************/
package nfse;

/*******************************************************************************
 * This class is a data structure for holding information about an index
 * instance. A "run" is a monotonically increasing number indicating the
 * iteration number for this sensor.
 * 
 * @author
 * 
 * This code is the property of Los Alamos National Laboratory and the
 * University of California, Copyright 2005
 */
public class Run {

    /***************************************************************************
     * Month of the data file (1-12)
     */
    private int month = -1;

    /***************************************************************************
     * Day of month of the data file (1-31)
     */
    private int day = -1;

    /***************************************************************************
     * Year of the data file (YYYY)
     */
    private int year = -1;

    /***************************************************************************
     * Monotonically increasing itteration of files in this day (1-n)
     */
    private int run = -1;

    /***************************************************************************
     * Unix time of the earliest record in the data file
     */
    private long minTime = -1;

    /***************************************************************************
     * Unix time of the latest record in the data file
     */
    private long maxTime = -1;

    /***************************************************************************
     * Sensor that generated the data
     */
    private int sensorID = -1;

    /***************************************************************************
     * The date that this run applies to
     */
    private nfse.query.QueryDate date = null;

    public String toString() {
        return month + "/" + day + "/" + year + " " + run + ", " + new java.sql.Timestamp(minTime * 1000) + "-"
                + new java.sql.Timestamp(maxTime * 1000);
    }

    /***************************************************************************
     * Returns a SQL standard date representation.
     * 
     * @return The SQL date string for this run (YYYY-MM-DD)
     */
    public String getSQLDateStr() {
        StringBuffer temp = new StringBuffer(year);
        temp.append("-");
        temp.append(month);
        temp.append("-");
        temp.append(day);
        return temp.toString();
    }

    /***************************************************************************
     * Returns the date representation as a string.
     * 
     * @return The date string for this run (YYYYMMDD)
     */
    public String getDateStr() {
        StringBuffer temp = new StringBuffer(year);
        if (month < 10)
            temp.append(0);
        temp.append(month);
        if (day < 10)
            temp.append(0);
        temp.append(day);
        return temp.toString();
    }

	/**
	 * @param month the month to set
	 */
	public void setMonth(int month) {
		this.month = month;
	}

	/**
	 * @return the month
	 */
	public int getMonth() {
		return month;
	}

	/**
	 * @param day the day to set
	 */
	public void setDay(int day) {
		this.day = day;
	}

	/**
	 * @return the day
	 */
	public int getDay() {
		return day;
	}

	/**
	 * @param year the year to set
	 */
	public void setYear(int year) {
		this.year = year;
	}

	/**
	 * @return the year
	 */
	public int getYear() {
		return year;
	}

	/**
	 * @param run the run to set
	 */
	public void setRun(int run) {
		this.run = run;
	}

	/**
	 * @return the run
	 */
	public int getRun() {
		return run;
	}

	/**
	 * @param minTime the minTime to set
	 */
	public void setMinTime(long minTime) {
		this.minTime = minTime;
	}

	/**
	 * @return the minTime
	 */
	public long getMinTime() {
		return minTime;
	}

	/**
	 * @param maxTime the maxTime to set
	 */
	public void setMaxTime(long maxTime) {
		this.maxTime = maxTime;
	}

	/**
	 * @return the maxTime
	 */
	public long getMaxTime() {
		return maxTime;
	}

	/**
	 * @param sensorID the sensorID to set
	 */
	public void setSensorID(int sensorID) {
		this.sensorID = sensorID;
	}

	/**
	 * @return the sensorID
	 */
	public int getSensorID() {
		return sensorID;
	}

	/**
	 * @param date the date to set
	 */
	public void setDate(nfse.query.QueryDate date) {
		this.date = date;
	}

	/**
	 * @return the date
	 */
	public nfse.query.QueryDate getDate() {
		return date;
	}
}